<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>认领记录管理</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css" rel="stylesheet">
    <style>
        body {
            overflow-x: hidden;
        }
        #sidebar {
            min-height: 100vh;
            box-shadow: 2px 0 5px rgba(0,0,0,0.1);
            position: fixed;
            left: 0;
            top: 0;
            z-index: 1000;
        }
        .main-content {
            margin-left: 0;
            transition: margin-left 0.3s;
            position: relative;
            z-index: 1;
        }
        @media (min-width: 768px) {
            .main-content {
                margin-left: 25%;
            }
        }
        @media (min-width: 992px) {
            .main-content {
                margin-left: 16.666667%;
            }
        }
    </style>
</head>
<body>
    <div class="container-fluid">
        <div class="row">
            <!-- 侧边导航栏 -->
            <div th:replace="fragments/sidebar :: sidebar"></div>

            <!-- 主内容区域 -->
            <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4 main-content">
                <div class="d-flex justify-content-between align-items-center mb-4">
                    <h2>认领记录管理</h2>
                </div>

                <!-- 搜索表单 -->
                <div class="card mb-4">
                    <div class="card-body">
                        <form th:action="@{/claim-record/list}" method="get" class="row g-3">
                            <div class="col-md-6">
                                <input type="text" name="claimer" th:value="${claimer}" class="form-control" placeholder="搜索认领人">
                            </div>
                            <div class="col-md-3">
                                <button type="submit" class="btn btn-primary w-100">搜索</button>
                            </div>
                            <div class="col-md-3">
                                <a th:href="@{/claim-record/list}" class="btn btn-outline-secondary w-100">重置</a>
                            </div>
                        </form>
                    </div>
                </div>

                <!-- 数据表格 -->
                <div class="card">
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-hover">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>物品标题</th>
                                        <th>认领人</th>
                                        <th>联系方式</th>
                                        <th>认领时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr th:each="record : ${page.records}">
                                        <td th:text="${record.id}"></td>
                                        <td th:text="${record.itemTitle}"></td>
                                        <td th:text="${record.claimer}"></td>
                                        <td th:text="${record.contact}"></td>
                                        <td th:text="${#temporals.format(record.claimTime, 'yyyy-MM-dd HH:mm')}"></td>
                                        <td>
                                            <div class="btn-group btn-group-sm">
                                                <a th:href="@{/claim-record/detail/} + ${record.id}" class="btn btn-outline-info">详情</a>
                                            </div>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>

                        <!-- 分页 -->
                        <nav th:if="${page.pages > 1}" class="mt-4">
                            <ul class="pagination justify-content-center">
                                <li class="page-item" th:classappend="${page.current == 1} ? 'disabled'">
                                    <a class="page-link" th:href="@{/claim-record/list(page=${page.current - 1}, size=${page.size}, claimer=${claimer})}">上一页</a>
                                </li>
                                <li th:each="i : ${#numbers.sequence(1, page.pages)}" class="page-item" th:classappend="${i == page.current} ? 'active'">
                                    <a class="page-link" th:href="@{/claim-record/list(page=${i}, size=${page.size}, claimer=${claimer})}" th:text="${i}"></a>
                                </li>
                                <li class="page-item" th:classappend="${page.current == page.pages} ? 'disabled'">
                                    <a class="page-link" th:href="@{/claim-record/list(page=${page.current + 1}, size=${page.size}, claimer=${claimer})}">下一页</a>
                                </li>
                            </ul>
                        </nav>
                    </div>
                </div>
            </main>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>